/**
  ******************************************************************************
  * @file           : client.cpp
  * @author         : chyang
  * @brief          : None
  * @attention      : None
  * @date           : 2024/3/13
  ******************************************************************************
*/
#include <ctime>
#include "rpc_client.h"

using grpc::Channel;
using grpc::ClientContext;
using grpc::ClientReaderWriter;


int main() {
    long long cout = 0;
    std::string addres = "127.0.0.1:5001";
    OcrRec upmes(addres); //grpc封装好的类，传入地址即可
    time_t t2 = time(0);
    time_t old = time(0);
    time_t t3;
    RResult res;
    clock_t start, ends;
    int numb = 0;
    while (1) {
        start = clock();
        numb++;
        std::string imp = "/media/chyang/data/dataset/detect/deepsort_dataset/test/Bipolar/v01_056375_01.jpg";
        if (numb >= 2) {
            break;
        }
        res.res_img = cv::imread(imp);
        bool b = upmes.RunOcr(res);
        if (!b) {
            std::cout << "error:\n" << res.info;
            system("pause");
            return 0;
        }
        cout++;
        t3 = time(0);
        ends = clock();
        std::cout << "\n测试：第 " << cout << "次, " << "用时：" << ends - start << "，已测时间：" << t3 - t2 << "\n";
        cv::imwrite("rec.jpg", res.res_img);
    }
    return 0;
}